#include <map>
#include "CLComRecord.h"
#include "CRecord.h"
#include "CLComMacro.h"

map<CLComString, CRecord*> cls_mapObjs;

CLComRecord* CLComRecord::CreateRecord(CLComString programid, IRecordOwer* ppRogram)
{
	CRecord* pR = NULL;
    map<CLComString, CRecord*>::iterator it = cls_mapObjs.find(programid);
	if (it != cls_mapObjs.end())
	{
		pR = it->second;
	}
	else
	{
		pR = new CRecord(ppRogram);
		cls_mapObjs[programid] = pR;
	}
	return pR;
}
CLComRecord* CLComRecord::GetInstance(CLComString programid)
{
	CRecord* pR = NULL;
    map<CLComString, CRecord*>::iterator it = cls_mapObjs.find(programid);
	if (it != cls_mapObjs.end())
	{
		pR = it->second;
	}
	return pR;
}
void CLComRecord::ReleaseInstance(CLComString programid)
{
    map<CLComString, CRecord*>::iterator it = cls_mapObjs.find(programid);
	if (it != cls_mapObjs.end())
	{
        CLCOM_BUFFER_RELEASE(it->second);
		cls_mapObjs.erase(it);
	}
}
